<%@ page pageEncoding="UTF-8"%>
<%@ include file="../commons/head.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%> 
<script type="text/javascript" src="${ctxStatic}/js/jquery.validate.min.js"></script>
<script type="text/javascript">
$(function(){
	$("#cellphone").click(function() {
		alert("跳转")
	})
	contractDe.init();
	
});

//创建对象
var contractDe = {}

contractDe.init = function() {
	// 初始化表单校验
	contractDe.initValidate();
}


contractDe.submitAdd = function() {
	$("#fm").submit();
}



/**
 * 初始化表单校验
 */
contractDe.initValidate = function() {// jQuery Validate
	$("#fm").validate({
		rules : {
			name : {
				required : true,
				isReceiveDate : true
			},
		},
		messages : {},
		submitHandler : function(form) {// 校验通过后执行
			contractDe.submitAddForm(form);
			return false;
		}
	});
}

contractDe.submitAddForm = function(form) {
	var url = "contractDet/save";
	var form =new FormData(document.getElementById("fm"));  
	$.ajax({
		url : url,
		method : "post",
		data : form,
		 async: true,  
         cache: false,  
		processData : false,
		contentType : false,
		success : function(data) {// 获取查询结果客户集合
			if(data == 1){//成功
			location.href = "${pageContext.request.contextPath}/contractDet?id=6";
			}else if (data == 2){
				error.innerHTML = "只能修改"+${contractInfo.receiveCyc }+"期";
			}else if (data == 3){
				error.innerHTML = "收款日期必须大于等于该期预计还款日"
			}else if (data == 4){
				error.innerHTML = "已经全部还完，不能再保存"
			}
		}
	});
}
	
</script>
<body >
	<h3>合同执行详情</h3>
	<div>
		<label style="margin-left: 0;">手机号码：</label><input id="cellphone"
			 style="width: 100px" readonly="readonly" > <label
			style="margin-left: 15px;">客户姓名：</label> <input id="name"
			class="easyui-textbox" style="width: 160px" readonly="readonly" ><br> <label
			style="margin-left: 0;">合同本金：</label><input id="principai"
			class="easyui-textbox" style="width: 100px" value="${contractInfo.principai }" readonly="readonly"> <label
			style="margin-left: 15px;">服务费率：</label> <input id="serFee"
			class="easyui-textbox" style="width: 160px" value="${contractInfo.serFee}" readonly="readonly">% <br> <label
			style="margin-left: 0;">合同生效日期：</label><input id="loanDate"
			class="easyui-textbox" style="width: 100px" value="${contractInfo.loanDateStr }" readonly="readonly"> <label
			style="margin-left: 15px;">合同期数：</label> <input id="cyc"
			class="easyui-textbox" style="width: 160px" value="${contractInfo.cyc }" readonly="readonly"> <br> <label
			style="margin-left: 0;">累计基础服务费：</label><input id="totalBaseAmount"
			class="easyui-textbox" style="width: 100px" value="${contractInfo.totalBaseAmount }" readonly="readonly"> <label
			style="margin-left: 15px;">累计增值服务费：</label> <input
			id="totalAddAmount" class="easyui-textbox" style="width: 160px" value="${contractInfo.totalAddAmount }" readonly="readonly"><br>
		<label style="margin-left: 0;">累计延迟服务费：</label><input
			id="totalDelayAmount" class="easyui-textbox" style="width: 100px" value="${contractInfo.totalDelayAmount }" readonly="readonly">
		<label style="margin-left: 15px;">累计收款：</label> <input
			id="totalReceiveAmount" class="easyui-textbox" style="width: 160px" value="${contractInfo.totalReceiveAmount }" readonly="readonly"> 
		<br> <label style="margin-left: 0;">强制结束收费：</label><input
			id="forceAmount" class="easyui-textbox" style="width: 100px" value="${contractInfo.forceAmount }" readonly="readonly">
		<label style="margin-left: 15px;">利润：</label> <input id="profit"
			class="easyui-textbox" style="width: 160px" value="${contractInfo.profit }"> <br>
	<hr>
	<table class="table table-hover" style="width: 90%">
		<thead>
			<tr>
				<th>期数</th>
				<th>预计还款日</th>
				<th>预计还款额</th>
				<th>实际还款日</th>
				<th>实际还款额</th>
				<th>基础服务费</th>
				<th>增值服务费</th>
				<th>剩余基础服务费</th>
				<th>累计基础服务费</th>
				<th>累计增值服务费</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${contractExeList }" var="c">
		<tr>
		<td>${c.cyc }</td>
		<td>${c.expectDateStr }</td>
		<td>${c.expectAmount }</td>
		<td>${c.actualDateStr }</td>
		<td>${c.actualAmount }</td>
		<td>${c.baseAmount }</td>
		<td>${c.addAmount }</td>
		<td>${c.residueBaseAmount }</td>
		<td>${c.totalBaseAmount }</td>
		<td>${c.totalAddAmount }</td>
		</tr>
		</c:forEach>
		</tbody>
	</table>
	<form id="fm"  method="post"  action="${pageContext.request.contextPath}/contractDe/save" role="form">
	<!--用来存储合同id  -->
	<input type="hidden" id="id" value="6" name="id">
	<span style="color: red">*</span><label style="margin-left: 0;">收款期数：</label>
	<input name="receiveCyc"  style="width: 100px" value="${contractInfo.receiveCyc }" required="required">
		<span style="color: red">*</span><label style="margin-left: 15px;">收款日期：</label> 
		<input name="receiveDate" type="text"   class="easyui-datebox" editable="false" style="width: 160px" value="${contractInfo.receiveDateStr }" required="required"> <br>
		<label style="margin-left: 0;">收款金额：</label>
	<input name="receiveAmount" style="width: 100px" value="${contractInfo.receiveAmount }" readonly="readonly">
</form>
</div>
		<div class="main-poptwobox">
					<button type="button" name="submitbutton" class='main-addbtnsure'
						onclick="contractDe.submitAdd()">保存</button>
						<span id="error" style="color: red"></span>
				</div>




</body>
</html>